<script setup lang="ts">
// ------------------use------------------
// #region

// #endregion
// ------------------静态变量------------------
// #region
const time = 30
let i = 30

// #endregion
// ------------------动态变量------------------
// #region

// #endregion
// ------------------ref-----------
// #region

// #endregion
// ------------------reactive------
// #region

// #endregion
// ------------------computed------
// #region

// #endregion
// ------------------生命周期------------------
// #region
onMounted(() => {
  init()
})
// #endregion
// ------------------内置方法---------------------
// #region

// #endregion
// ------------------方法---------------------
// #region
function init() {
  const loop3 = setInterval(() => {
    if (i > 40) {
      clearInterval(loop3)
      document.querySelector('.thirdDigit')!.textContent
        = `${4}`
    }
    else {
      document.querySelector('.thirdDigit')!.textContent
        = `${randomNum()}`
      i++
    }
  }, time)
  const loop2 = setInterval(() => {
    if (i > 80) {
      clearInterval(loop2)
      document.querySelector('.secondDigit')!.textContent
        = `${0}`
    }
    else {
      document.querySelector('.secondDigit')!.textContent
        = `${randomNum()}`
      i++
    }
  }, time)
  const loop1 = setInterval(() => {
    if (i > 100) {
      clearInterval(loop1)
      document.querySelector('.firstDigit')
      && (document.querySelector(
        '.firstDigit',
      )!.textContent = `${4}`)
    }
    else {
      document.querySelector('.firstDigit')!.textContent
        = randomNum().toString()
      i++
    }
  }, time)
  onBeforeUnmount(() => {
    clearInterval(loop1)
    clearInterval(loop2)
    clearInterval(loop3)
  })
}
function randomNum() {
  return Math.floor(Math.random() * 9) + 1
}
// #endregion
</script>

<template>
  <div
    class="width-fill height-fill align-center flex justify-center bg-white"
  >
    <div class="error">
      <div class="container-floud">
        <div style="text-align: center">
          <div class="container-error-404">
            <div class="clip">
              <div class="shadow">
                <span class="digit thirdDigit" />
              </div>
            </div>
            <div class="clip">
              <div class="shadow">
                <span class="digit secondDigit" />
              </div>
            </div>
            <div class="clip">
              <div class="shadow">
                <span class="digit firstDigit" />
              </div>
            </div>
            <div class="msg">
              OH!
              <span class="triangle" />
            </div>
          </div>
          <h2 class="h1">
            很抱歉，你访问的页面找不到了
          </h2>
          <el-button
            type="primary"
            link
            @click="$router.back()"
          >
            返回
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.error .clip .shadow {
  height: 180px;
}
.error .clip:nth-of-type(2) .shadow {
  width: 130px;
}
.error .clip:nth-of-type(1) .shadow,
.error .clip:nth-of-type(3) .shadow {
  width: 250px;
}
.error .digit {
  width: 150px;
  height: 150px;
  line-height: 150px;
  font-size: 120px;
  font-weight: bold;
}
.error h2 {
  font-size: 32px;
}
.error .msg {
  top: 0px;
  left: 70px;
  width: 80px;
  height: 80px;
  line-height: 80px;
  font-size: 32px;
}
.error span.triangle {
  top: 70%;
  right: 0%;
  border-left: 20px solid #535353;
  border-top: 15px solid transparent;
  border-bottom: 15px solid transparent;
}
.error .container-error-404 {
  position: relative;
  height: 250px;
}
.error .container-error-404 .clip {
  display: inline-block;
  transform: skew(-45deg);
}
.error .clip .shadow {
  overflow: hidden;
}
.error .clip:nth-of-type(2) .shadow {
  overflow: hidden;
  position: relative;
  box-shadow: inset 20px 0px 20px -15px rgba(150, 150, 150, 0.8),
    20px 0px 20px -15px rgba(150, 150, 150, 0.8);
}
.error .clip:nth-of-type(3) .shadow:after,
.error .clip:nth-of-type(1) .shadow:after {
  content: '';
  position: absolute;
  right: -8px;
  bottom: 0px;
  z-index: 9999;
  height: 100%;
  width: 10px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(173, 173, 173, 0.8),
    transparent
  );
  border-radius: 50%;
}
.error .clip:nth-of-type(3) .shadow:after {
  left: -8px;
}
.error .digit {
  position: relative;
  top: 8%;
  color: white;
  background: #1e9fff;
  border-radius: 50%;
  display: inline-block;
  transform: skew(45deg);
}
.error .clip:nth-of-type(2) .digit {
  left: -10%;
}
.error .clip:nth-of-type(1) .digit {
  right: -20%;
}
.error .clip:nth-of-type(3) .digit {
  left: -20%;
}
.error h2 {
  font-size: 24px;
  color: #a2a2a2;
  font-weight: bold;
}
.error .tohome {
  font-size: 16px;
  color: #07b3f9;
}
.error .msg {
  position: absolute;
  z-index: 9999;
  display: block;
  background: #535353;
  color: #a2a2a2;
  border-radius: 50%;
  font-style: italic;
}
.error .triangle {
  position: absolute;
  z-index: 999;
  transform: rotate(45deg);
  content: '';
  width: 0;
  height: 0;
}
//------------------组件样式------------------
//-------------样式穿透-------------
</style>
